#include "shift_row.h"
#include "types.h"

#include <string.h>

static void shift_row_inside(byte* row, int st_counts)
{
	int i;
	byte tmp[4];
	for(i = 0; i < 4; ++i)
	{
		int col = (i - st_counts + 4) % 4;
		tmp[col] = row[i];
	}
	memcpy(row, tmp, 4);
}

void shift_row(byte* state)
{
	int st_counts[] = {
		0,1,2,3
	};
	int row = 0;
	for( row = 0; row < 4; ++row)
	{
		shift_row_inside(state + 4*row, st_counts[row]);
	}
}
